#pragma once

#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string>
#include <vector>
#include <opencv2/opencv.hpp>

class UDPHandler {
public:
    UDPHandler(const char* server_ip = "192.168.0.2", int server_port = 5005);
    ~UDPHandler();
    
    bool init();
    bool receive_image(cv::Mat& image);
    bool send_result(const std::string& result);
    void close_connection();

private:
    static const int BUFFER_SIZE = 1440;
    
    const char* server_ip_;
    int server_port_;
    int sockfd_;
    bool is_initialized_;
    std::vector<uchar> image_data_;
    struct sockaddr_in client_addr_;
};
